package ua.edu.onu.mystringer;

public class myStringer implements strInterface {

    public String trim(String str) {
        str.replaceAll("^\\s+","");
        str.replaceAll("\\s+$","");
        return str;
    }

    public String trunkMessage(String replacement, String message) {
        String complete_replacement = replacement.replaceAll(message, "");
        return complete_replacement;
    }

    public boolean isDigit(String str) {
        StringBuilder isDigitString = new StringBuilder(str);
        boolean flag = false;
        for (int i = 0; i < str.length(); i++) {
            if (Character.isDigit(isDigitString.charAt(i))) {
                flag = true;
            } else {
                flag = false;
                break;
            }
        }
        return flag;
    }

    public boolean isLetter(String str) {
        StringBuilder isLetterString = new StringBuilder(str);
        boolean flag = false;
        for (int i = 0; i < str.length(); i++) {
            if (Character.isLetter(isLetterString.charAt(i))) {
                flag = true;
            } else {
                flag = false;
                break;
            }
        }
        return flag;
    }

    public boolean isMix(String str) {
        if (!isDigit(str) && !isLetter(str)) {
            return true;
        } else {
            return false;
        }
    }

    public String append(String str, String add) {
        StringBuilder builder = new StringBuilder(str);
        return builder.append(add).toString();
    }

    public String setLength(int i) {
        char str[] = new char[i];
        return str.toString();
    }

    public String trunkLength(String str, int trunklength) {
        StringBuilder trunkAdder = new StringBuilder(str);
        if (trunklength > trunkAdder.length()) {
            while (trunklength > trunkAdder.length()) {
                trunkAdder.append(" ");
            }
        }
        if (trunklength == trunkAdder.length()) {
            return trunkAdder.toString();
        } else
            trunkAdder.delete(trunklength, trunkAdder.length());
        return trunkAdder.toString();
    }

    public String addLeaderSymbols(String str, String leaderSymbol) {
        return leaderSymbol + str;
    }

    @Override
    public String addTrailerSymbols(String str, String trailerSymbol) {
        return str + trailerSymbol;
    }

    public static void main(String[] args) {

    }
}

